package com.fesine.ext.controller;

import com.fesine.ext.model.User;
import com.fesine.ext.service.UserServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Fesine on 2016/1/9.
 */
@Controller
@RequestMapping("/user")
public class UserController {

    private UserServiceI userService;

    public UserServiceI getUserService() {
        return userService;
    }

    @Autowired
    public void setUserService(UserServiceI userService) {
        this.userService = userService;
    }

    @RequestMapping("/{id}/showUser")
    public String showUser(@PathVariable Integer id,HttpServletRequest request) {
        User user = userService.getUserById(id);
        request.setAttribute("user",user);
        return "/jsp/showUser";
    }
}
